<?php namespace Phpcmf\Controllers\Member;

class Home extends \Phpcmf\Member\Module
{

	// 内容列表
	public function index() {
		$this->_Member_List();
	}

	public function add() {
		// get 参数 cid
		$cid = \Phpcmf\Service::L('input')->get('cid');
		$quan_data = \Phpcmf\Service::M()->db->table('1_quan')->where('id', $cid)->get()->getRowArray();
		if($quan_data['kaifangfabu'] == 0) {
			$this->_json('0', '没有开通发帖');
		}
		//统计用户申请的圈子
		$quan_tongji = \Phpcmf\Service::M()->db->table('1_quan')->where('uid', $this->uid)->countAllResults();
		//圈子设置
		$quanzhi_shezhi_0 = \Phpcmf\Service::M()->table('1_quan_shezhi')->where('dirname', 'quan')->getRow();
		$quanzhi_shezhi = dr_string2array($quanzhi_shezhi_0['setting']);
		$quan_shuliang_0 = $quanzhi_shezhi['pages']['quan_shuliang'];
		$quan_leixing = $quanzhi_shezhi['pages']['quan_leixing'];
		// 如果$quan_shuliang_0不存在，那么默认$quan_shuliang = 3，否则$quan_shuliang = $quan_shuliang_0;
		if(!$quan_shuliang_0){
			$quan_shuliang = 3;
		} else {
			$quan_shuliang = $quan_shuliang_0;
		}
		if($quan_leixing ==1){
			$this->_json('0', '不能申请圈子');
		}
		if($quan_shuliang >= $quan_tongji) {
			$this->_json('0', '每人只限制申请 '.$quan_shuliang.' 个圈子');
		}
		$this->_Member_Add();
	}

	public function edit() {
		$this->_Member_Edit();
	}

	public function del() {
		$this->_Member_Del();
	}
}
